#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
class QLabel;
class QPushButton;
class QVBoxLayout;
class QTcpsocket;
class SetTimeUIDialog;
class QHBoxLayout;
class QNetworkReply;
class QNetworkAccessManager;

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    //
    int widthUI=500;
    int heightUI=200;
    //右键菜单
    QMenu *menu;
    QAction *actClose;
    QAction *actSet;
    QAction *actShowMinSize;

    QPoint dPosion;//相对位置差
    //UI
    QLabel *labelIcon;
    QLabel *labelTime;
    QLabel *labelDate;
    QLabel *labelWeather;
    QPushButton *btnShowDate;
    QPushButton *btn12H;
    QVBoxLayout *mainLayout;
    QHBoxLayout *hBoxLayout;
    //访问菜单
    bool menuIsVisible;

    //天气
    QNetworkReply *reply;
    QNetworkAccessManager *manager;
    QString apiWeather="http://v1.yiketianqi.com/free/day?appid=35269352&appsecret=Inq9mkx1&unescape=1";
private:
    //设置时间显示
    bool isShowIcon;
    bool isShow12H;
    bool isShowS;
    bool isShowDate;
    double opacityShow;
    double opacityHide;
    QFont font;//字体
    QColor color;//颜色

    //移动设置
    bool moving=false;

    SetTimeUIDialog *setTimeUIDialog;
public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void InitAll();
    void InitSet();
    void InitUI();
    void InitRigtUI();
    void InitWeahter();
    void updateTime();
    void parseWeatherJsonData(QByteArray data);
private:
    Ui::MainWindow *ui;
private slots:
    void do_actSet_triggered();
    void readHttpReply(QNetworkReply *reply);
    // QWidget interface
protected:
    virtual void enterEvent(QEnterEvent *event) override;
    virtual void leaveEvent(QEvent *event) override;
    virtual void mousePressEvent(QMouseEvent *event) override;
    virtual void mouseMoveEvent(QMouseEvent *event) override;
    virtual void mouseReleaseEvent(QMouseEvent *event) override;
};



#endif // MAINWINDOW_H
